package org.loong.crypto.common.exception;

import java.security.Key;
import java.util.Arrays;

public class InvalidKeyTypeException extends KeyException {

    private static final long serialVersionUID = 1L;

    /**
     * Creates a new key type exception.
     *
     * @param expectedKeyClass The expected key class. Should not be {@code null}.
     */
    public InvalidKeyTypeException(final Class<? extends Key> expectedKeyClass) {
        super("Invalid key: Must be an instance of " + expectedKeyClass);
    }

    /**
     * Creates a new key type exception.
     *
     * @param expectedKeyInterface The expected key interfaces. Should not be {@code null}.
     * @param additionalInterfaces Additional interfaces the key is required to implement.
     */
    public InvalidKeyTypeException(final Class<? extends Key> expectedKeyInterface, final Class<?>... additionalInterfaces) {
        super("Invalid key: Must be an instance of " + expectedKeyInterface + " and implement all of the following interfaces " + Arrays.toString(additionalInterfaces));
    }
}
